package com.etc.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.etc.entity.Users;
import com.etc.service.UserService;

//xx/api/listUser
@Controller
@RequestMapping("api")
public class UsersController {
	//控制器要注入一个UserSerivice对象
	@Resource(name="userService")
	private UserService userService;

	@RequestMapping(value = "listUser")
	public String getUser(Model model) {
		model.addAttribute("list", userService.getUsers());
		return "userlist";
	}
	
	@RequestMapping(value = "listUserById")
	public String getUserById(int userId,Model model) {
		model.addAttribute("u", userService.getUsersById(userId));
		return "userlist";
	}
}
